package com.kob.kobbackend.controller.user.account;

import com.kob.kobbackend.service.user.account.UserAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/api/user/account/")
public class UserAccountController {
    @Autowired
    private UserAccountService userAccountService;

    @PostMapping("token/")
    public Map<String,String> getToken(@RequestBody Map<String,String> map){
        String username = map.get("username");
        String password = map.get("password");
        return userAccountService.getToken(username,password);
    }

    @GetMapping("info/")
    public Map<String,String> getInfo(){
        return userAccountService.getinfo();
    }

    @PostMapping("register/")
    public Map<String,String> register(@RequestBody Map<String,String> map){
        String username = map.get("username");
        String password = map.get("password");
        String confirmPassword = map.get("confirmPassword");
        return userAccountService.register(username,password,confirmPassword);
    }
}
